package com.superpeer.baseproject.utils;

import android.util.Log;
import android.view.View;

import java.util.Calendar;

/**
 * Created by lpq on 2017/7/18.
 * 防连点
 */

public abstract class NoDoubleListener implements View.OnClickListener {
    public static final int MIN_CLICK_DELAY_TIME = 3000;
    private static final String TAG ="NoDoubleListener" ;
    private long lastClickTime = 0;

    @Override
    public void onClick(View v) {
        long currentTime = Calendar.getInstance().getTimeInMillis();
        if (currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) {
            lastClickTime = currentTime;
            onNoDoubleClick(v);
        }else {
            Log.w(TAG,"点击过快");
        }
    }
    protected abstract void onNoDoubleClick(View v);
}